-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TFC usage detection #1208
Add TFC usage detection #1208
Conversation
61ff41e
to
a489c84
Compare
This builds on the existing methods to detect remote backend usage and adds detection of cloud blocks in the terraform block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from that in-line question about how we handle empty/default hostnames, this LGTM and works as expected:
2023/03/13 09:36:22 opts.go:205: Posting server notification "telemetry/event" {"v":1,"name":"moduleData","properties":{"cloud":true,"cloud.hostname":"custom-hostname","moduleId":"d1a79a40-a1df-414d-03ef-d1ff802e721d","tfVersion":"1.4.0"}}
// Required for Terraform Enterprise; | ||
// Defaults to app.terraform.io for Terraform Cloud | ||
if hostname == "" { | ||
hostname = "app.terraform.io" | ||
} | ||
|
||
// anonymize any non-default hostnames | ||
if hostname != "app.terraform.io" { | ||
hostname = "custom-hostname" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks slightly inconsistent with how we check & report hostnames below for backends.
I don't have too strong opinion on whether we should be reporting the difference between default and empty (implied default) hostname, but I do think we should approach both the same way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to https://developer.hashicorp.com/terraform/cli/cloud/settings#hostname, hostname is optional, and is an empty string if not specified. Using the same logic as backend would result is us sending an empty string in telemetry, which defeats the purpose in doing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would assume that telemetry metrics with empty string still get sent through? As in - we'd still be able to see any cloud
blocks parsed, the only difficulty would be treating empty strings as app.terraform.io
when processing the data.
To put it differently - I'm happy with your implementation - which implies that we do no further interpretation of empty strings in AppInsights, but in that case I think we should do the same for the remote backend
below, otherwise we end up comparing apples to pears.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sending empty data is allowed.
If the default is known, I don't see the need for sending empty strings and then having to do conversion when reporting.
I'll open a ticket for backend reporting.
Co-authored-by: Radek Simko <[email protected]>
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
This builds on the existing methods to detect remote backend usage and adds detection of cloud blocks in the terraform block.
Closes #912